﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ServiceImplementation.Translator
{
    /// <summary>
    /// Define AuthorityDTO Translator
    /// </summary>
    class AuthorityDTOTranslator
    {
        /// <summary>
        /// To Translate AuthorityDTO to AuthorityBusinessEntity
        /// </summary>
        /// <param name="authorityDTO"></param>
        /// <returns></returns>
        public static BLL.Authority TranslateDTOToBusiness(DataContracts.AuthorityDTO authorityDTO)
        {
            BLL.Authority authorityBE = new BLL.Authority();
            authorityBE.AuthorityId = authorityDTO.AuthorityId;
            authorityBE.AuthorityName = authorityDTO.AuthorityName;
            if (authorityDTO.Level == null)
            {
                authorityBE.Level = null;
            }
            else
            {
                authorityBE.Level = Translator.AuthorityLevelDTOTranslator.TranslateDTOToBusiness(authorityDTO.Level);
            }
            return authorityBE;
        }

        /// <summary>
        /// To Translate AuthorityBusinessEntity to AuthorityDTO
        /// </summary>
        /// <param name="authorityBE"></param>
        /// <returns></returns>
        public static DataContracts.AuthorityDTO TranslateBusinessToDTO(BLL.Authority authorityBE)
        {
            DataContracts.AuthorityDTO authorityDTO = new DataContracts.AuthorityDTO();
            authorityDTO.AuthorityId = authorityBE.AuthorityId;
            authorityDTO.AuthorityName = authorityBE.AuthorityName;
            if (authorityBE.Level == null)
            {
                authorityDTO.Level = null;
            }
            else
            {
                authorityDTO.Level = Translator.AuthorityLevelDTOTranslator.TranslateBusinessToDTO(authorityBE.Level);
            }
            return authorityDTO;
        }
    }
}
